package com.thoughtworks.model;
/**
 * this class represent the edge of graph
 * @author Administrator
 *
 */
public class Edge {
	
	private String startNode;  //start node of edge
	
	private String endNode;    //end node of edge
	
	private int weight;        //the length of edge
	
	public Edge(String startNode, String endNode, int weight) {
		this.startNode = startNode;
		this.endNode = endNode;
		this.weight = weight;
	}

	public String getStartNode() {
		return startNode;
	}

	public void setStartNode(String startNode) {
		this.startNode = startNode;
	}

	public String getEndNode() {
		return endNode;
	}

	public void setEndNode(String endNode) {
		this.endNode = endNode;
	}

	public int getWeight() {
		return weight;
	}

	public void setWeight(int weight) {
		this.weight = weight;
	}
	
	public boolean startWith(String node) {
		return this.startNode.equals(node);
	}
	
	public boolean endWith(String node) {
		return this.endNode.equals(node);
	}
	
	@Override
	public boolean equals(Object obj) {
		if(!(obj instanceof Edge)){
			return false;
		}
		Edge edge = (Edge)obj;
		return this.startNode.equals(edge.startNode) && this.endNode.equals(edge.endNode) && this.weight == edge.weight;
	}
	
	@Override
	public String toString() {
		return "(" + this.startNode + "->" + this.endNode + ") = " + this.weight; 
	}
}

